<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/FCKeditor.tld" prefix="fck" %>
<%@page import="java.util.*,model.*,util.*,control.*,java.text.*"%>
<%@ taglib uri="/WEB-INF/displaytag.tld" prefix="display"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
<style type="text/css">
<!--
.form1 {width:300px;}
-->
</style>
<body>

            <%
           /*
           *验证权限
           *author 宋智洋
           *data 2011-11-26
           *update 胡瑾
           *data 2011-12-01
           *增加了userId
           */
			String flag = (String)session.getAttribute("flag");
			String userId = (String)session.getAttribute("userId");
			int studentId = Integer.parseInt(userId);
						
			if (flag != "student"|| flag==null )
			{
				%>
            <script language="javascript">
				     alert("您没有学生权限,请重新登录"); window.location.href="../../index.jsp";
				    </script>
            <%
				
			}else{
				Student student = new Student();
				StudentControl sc = new StudentControl();
				student = sc.GetStudent(studentId);
				out.print("<p>"+student.getStudentName()+"   欢迎您</p>");
			}
           %>
           

         <%
		
		//需要用到problem answerlog
		
				int k = 0;
				request.setCharacterEncoding("utf-8");
				int pages = ParamUtil.getInt(request,"pages",1);
				int rowsPerPage = ParamUtil.getInt(request,"pageSize",20);
				String testTime = ParamUtil.getString(request,"testTime");
				
				Problem problem = new Problem();
				ProblemControl pc = new ProblemControl();
				Answerlog answerlog = new Answerlog();
				AnswerlogControl ac = new AnswerlogControl();

 		%>
  <!--这个from控制了分页!!!-->
  <form method="post" class="form1" action="problem_history_list.jsp?testTime=<%=testTime %>">
<table width="300" border="1" cellpadding="2" cellspacing="0" bordercolor="#333333" style="BORDER-COLLAPSE: collapse">
      <tr align="center">
        <th>序号</th>
        <th>试题编号</th>
        <th>题目</th>
        <th>正确与否</th>
        <th>正确答案</th>
      </tr>
      <%
				List<Answerlog>list = new ArrayList<Answerlog>();
				list = (List)ac.GetAnswerlog();
		
				for(int i = 0; i<list.size();i++)
				{
					answerlog = list.get(i);
					//System.out.println(answerlog.getTestTime()+"   chuanlai   "+testTime);
										
					if(answerlog.getStudentId()== studentId && answerlog.getTestTime().equals(testTime) )
					{
						problem = pc.GetProblem(answerlog.getId());
			
						String is_correct;
						if(answerlog.getFlag().equals("1"))
							is_correct = "正确";
						else
							is_correct = "错误";
			
						k++;
						String correct=problem.getCorrect();
						String correct_str=null;
						if(correct.equals("A"))
							correct_str = problem.getA();
						if(correct.equals("B"))
							correct_str = problem.getB();						
						if(correct.equals("C"))
							correct_str = problem.getC();
						if(correct.equals("D"))
							correct_str = problem.getD();
		%>
          <tr>
            <td><%=k%></td>
            <td><%=answerlog.getId()%></td>
            <td><div style="width:100%;height:100;overflow-x:hidden;overflow-y:scroll"><%=problem.getContent()%></div></td>
            <td><%=is_correct%></td>
            <td><%=correct_str%></td>
          </tr>
      <%
	  	 }//if
				 }//for
			    	%>
    </table>
       <br>
        <%
		out.println(AnswerlogControl.pageInstance.getToolsMenu(pages));
		%>
        <br>
  </form>


</html>